<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>32题求1-100和</title>
    <style>
        div {
            width: 100%;
            
        }
        span {
            display: block;
            width: 100%;
        }
    </style>
    <script>
        function getSum() {
            let sum = 0;
            for (let i = 1; i <= 100; i++) {
                sum += i;
            }
            let span = document.getElementById('sum');
            span.innerHTML = `1-100总和为：${sum}`;
        }
    </script>
</head>
<body>
    <div>
        点击按钮查看1-100的总和<input type="button" value="查看" onclick="getSum()">
        <span id="sum"></span>
    </div>
</body>
</html>